package no.ntnu.fp.gui.listeners;

import no.ntnu.fp.gui.events.AddOrUpdateAppointmentEvent;
import no.ntnu.fp.services.AppointmentService;

public class AddAppointmentListener implements GuiListener<AddOrUpdateAppointmentEvent>{
	private final AppointmentService appointmentService;
	
	public AddAppointmentListener(AppointmentService appointmentService) {
		this.appointmentService = appointmentService;
	}

	@Override
	public void handleEvent(AddOrUpdateAppointmentEvent evt) {
		switch (evt.getType()) {
		case ADD: 
			appointmentService.addAppointment(evt.getAppointment());
			break;
		case UPDATE:
			appointmentService.updateAppointment(evt.getAppointment());
			break;
		}
	}

	@Override
	public boolean isLongRunningListener() {
		return false;
	}

}
